package abs.service;

import abs.domain.Companias;
import abs.domain.Documentos;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/absWeb-security-context.xml",
		"file:./resources/absWeb-service-context.xml",
		"file:./resources/absWeb-dao-context.xml",
		"file:./resources/absWeb-web-context.xml" })
@Transactional
public class DocumentosServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected DocumentosService service;

	/**
	 * Instantiates a new DocumentosServiceTest.
	 *
	 */
	public DocumentosServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Documentos entity
	 * 
	 */
	@Test
	public void deleteDocumentos() {
		// TODO: JUnit - Populate test inputs for operation: deleteDocumentos 
		Documentos documentos = new abs.domain.Documentos();
		service.deleteDocumentos(documentos);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Companias entity
	 * 
	 */
	@Test
	public void saveDocumentosCompanias() {
		// TODO: JUnit - Populate test inputs for operation: saveDocumentosCompanias 
		String co030codi = null;
		Companias related_companias = new abs.domain.Companias();
		Documentos response = null;
		response = service.saveDocumentosCompanias(co030codi, related_companias);
		// TODO: JUnit - Add assertions to test outputs of operation: saveDocumentosCompanias
	}

	/**
	 * Operation Unit Test
	 * Load an existing Documentos entity
	 * 
	 */
	@Test
	public void loadDocumentoss() {
		Set<Documentos> response = null;
		response = service.loadDocumentoss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadDocumentoss
	}

	/**
	 * Operation Unit Test
	 * Save an existing Documentos entity
	 * 
	 */
	@Test
	public void saveDocumentos() {
		// TODO: JUnit - Populate test inputs for operation: saveDocumentos 
		Documentos documentos_1 = new abs.domain.Documentos();
		service.saveDocumentos(documentos_1);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Documentos entity
	 * 
	 */
	@Test
	public void countDocumentoss() {
		Integer response = null;
		response = service.countDocumentoss();
		// TODO: JUnit - Add assertions to test outputs of operation: countDocumentoss
	}

	/**
	 * Operation Unit Test
	 * Return all Documentos entity
	 * 
	 */
	@Test
	public void findAllDocumentoss() {
		// TODO: JUnit - Populate test inputs for operation: findAllDocumentoss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Documentos> response = null;
		response = service.findAllDocumentoss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllDocumentoss
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Companias entity
	 * 
	 */
	@Test
	public void deleteDocumentosCompanias() {
		// TODO: JUnit - Populate test inputs for operation: deleteDocumentosCompanias 
		String documentos_co030codi = null;
		String related_companias_co000nocia = null;
		Documentos response = null;
		response = service.deleteDocumentosCompanias(documentos_co030codi, related_companias_co000nocia);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteDocumentosCompanias
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findDocumentosByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findDocumentosByPrimaryKey 
		String co030codi_1 = null;
		Documentos response = null;
		response = service.findDocumentosByPrimaryKey(co030codi_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findDocumentosByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
